import store from '@/store'
import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    component: HomeView
  },
  {
    path: '/',
    redirect: 'home'
  },
    // {
  //   path: '/about',
  //   name: 'about',
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
  {
    path: '/goods',
    component: () => import(/* webpackChunkName: "about" */ '../views/Goods.vue')
  },
  {
    path: '/free',
    component: () => import(/* webpackChunkName: "about" */ '../views/Free.vue')
  },
  {
    path: '/order',
    component: () => import(/* webpackChunkName: "about" */ '../views/Order.vue')
  },
  {
    path: '/user',
    redirect:'/user/cart',
    component: () => import(/* webpackChunkName: "about" */ '../views/User.vue'),
    children:[
      {
        path: 'cart',
        component: () => import(/* webpackChunkName: "about" */ '@/components/user/Cart.vue'),
      }
    ]
  },
  {
    path: '/details',
    component: () => import(/* webpackChunkName: "about" */ '../views/Details.vue')
  },
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
if(onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}


export default router
